class Solution {
public:
    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {
        int n=customers.size(),ans=0;
        int s[2]{};
        for(int left=0,right=0;right<n;++right)
        {
            s[grumpy[right]]+=customers[right];
            while(left<right&&right-left+1>minutes)
            {
                s[1]-=grumpy[left]?customers[left]:0;
                ++left;
            }
            ans=max(ans,s[1]);
        }
        return s[0]+ans;
    }
};